define(function(){
    return function(id, price){
        const goodsMsg = localStorage.getItem("goodsMsg") ? JSON.parse(localStorage.getItem("goodsMsg")) : [];
        if(goodsMsg.length < 1){
            goodsMsg.push({
                id:id,
                num:1,
                flag:0,
                price:Number(price)
            })
        }else{
            let i = 0;
           const f = goodsMsg.some((val,index)=>{
                i = index;
                return val.id == id;
            })
            if(f){
                goodsMsg[i].num++;
            }else{
                goodsMsg.push({
                    id:id,
                    num:1,
                    flag:0,
                    price:Number(price)
                })
            }
        }
        localStorage.setItem("goodsMsg",JSON.stringify(goodsMsg));
    }
})